package java3_31;

import java.io.File;

/**
 *  输入一个目录，求这个目录占用的空间大小
 */
public class Homework0 {
    public static void main(String[] args) {
        String path = "G:\\JAVA84";

        print(path);
    }

    public static void print(String fatherPath){
        long size = 0;
        File father = new File(fatherPath);
        if (father.exists()&&father.isDirectory()){
            String[] list = father.list();
            String[] child = list;
            for (String path2:child) {
                String path3 = fatherPath +"\\"+path2;
                File file = new File(path3);
                if (!file.isDirectory()){
//                    System.out.println(file.getName());
                     size = size+file.length();
                }else {
                    print(path3);
//                    System.out.println(file.getName());
                }
            }

        }
        System.out.println(size);
    }

}
